refactor(ui): shared uPlot axis/cursor/range helpers#160
Merged
Conversation
The theme axis chrome ({ stroke: AXIS_TEXT, grid: { stroke: AXIS_GRID },
ticks: { stroke: AXIS_TICK } }) plus label styling, the integer-tick formatter,
the cursor-sync config, and the degenerate-span range guard were copy-pasted
into every chart across the apps. Collapse them into @calab/ui/chart:
- chartAxis(overrides) / labeledAxis(label, overrides) — axis chrome + labels
- integerTickValues / hiddenTickValues — reusable formatters
- syncCursor(key) / staticCursor — cursor configs
- safeRange(padFrac) — the zero-span guard (uPlot crashes on a [v, v] range)
Migrate the live direct-SolidUplot charts to the helpers: AsymptoteTrends,
KernelConvergence, KernelDisplay, HistogramCard, and the shared TracePanel.
Behavior-preserving — no visual change (verified in-browser across all tabs).
Dead components (drilldown/*, SubsetVariance — imported nowhere) are left for
the cleanup pass rather than migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The audit found the same uPlot boilerplate copy-pasted into every chart component across the apps:
{ stroke: AXIS_TEXT, grid: { stroke: AXIS_GRID }, ticks: { stroke: AXIS_TICK } }— plus consistent label styling (6+ copies).valuesformatter.{ sync: { key, setSeries: true } }and the static{ drag: { x: false, y: false } }.drawAxesGridcrashes on a zero[v, v]span), re-implemented in AsymptoteTrends and inline elsewhere.This collapses them into one place in
@calab/ui/chart(axis-helpers.ts):chartAxis(overrides)/labeledAxis(label, overrides)— axis chrome + labelsintegerTickValues/hiddenTickValues— reusable axisvaluesformatterssyncCursor(key)/staticCursor— cursor configssafeRange(padFrac)— the zero-span guardMigrated
The live direct-
SolidUplotcharts now use the helpers: AsymptoteTrends, KernelConvergence, KernelDisplay, HistogramCard, and the shared TracePanel (which backs TraceInspector + CaTune). This centralizes the chart chrome so all apps stay consistent — per the "CaDecon is one of several CaLab apps" guidance.Dead components (
drilldown/*,SubsetVariance— imported nowhere) are not migrated; they're left for the dead-code cleanup pass.Behavior
Pure refactor — no visual or behavioral change. Verified in-browser across Asymptote / Kernel / Distributions / Kernel Shape / Trace Inspector: identical rendering, axes/colors/markers intact, 0 console errors.
Checks
typecheck, eslint, prettier, and all 289 TS tests pass.
Follow-ups (deferred)
Legend unification (fold KernelDisplay + AsymptoteTrends custom swatch markup and KernelConvergence's uPlot-native legend onto the shared
TraceLegend) — the other half of the chart-primitives consolidation — and the dead-code removal.🤖 Generated with Claude Code